//
// Created by Administrator on 2025-07-24.
//

// ProtobufBinaryManager.h

#pragma once
#include <string>
#include <map>
#include <cstdint>
#include <google/protobuf/message.h>

class ProtobufBinaryManager
{
public:
    enum BinType
    {
        BINARY_NONE = 0,
        ADDRESS = 1,
        PERSON = 2,
        BINARY_VAILD_MAX
    };

    ProtobufBinaryManager();

    bool serializeToBuffer(uint8_t* buffer, uint32_t& totalSize);
    bool deserializeFromBuffer(const uint8_t* buffer, uint32_t totalSize);

private:
    bool serializeAddress(std::string& out);
    bool serializePerson(std::string& out);

    void deserializeAddress(const std::string& data);
    void deserializePerson(const std::string& data);

    std::map<uint32_t, std::string> binaryMap;  // 保存每个type对应的序列化数据
};
